package com.zzz.gp.controller;

import com.zzz.gp.dao.GpMapper;
import com.zzz.gp.service.CommonService;
import com.zzz.gp.service.analyse.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Set;

/**
 * @description:
 * @author: ZZZ
 * @time: 2021/12/14 9:54
 */
@Slf4j
@RestController
@RequestMapping("/analyse")
public class AnalyseController {
    @Autowired
    private A1Service A1;
    @Autowired
    private A2Service A2;
    @Autowired
    private A3Service A3;
    @Autowired
    private A4Service A4;
    @Autowired
    private A5Service A5;
    @Autowired
    private A17Service A17;
    @Autowired
    private V17Service V17;
    @Autowired
    private ADailyLimit1Service aDailyLimit1Service;
    @Autowired
    private ADailyLimit2Service aDailyLimit2Service;
    @Autowired
    private ADailyLimit3Service aDailyLimit3Service;
    @Autowired
    private GpMapper gpMapper;
    @Autowired
    private LPService lp;

    @Autowired
    private RiseProportionService riseProportionService;

    @Autowired
    private CommonService commonService;

    @GetMapping("/month")
    public String monthData() {
        return commonService.monthData().toString();
    }

    @GetMapping("/week")
    public String weekData() {
        return commonService.weekData().toString();
    }

    @GetMapping("/day")
    public String dayData() {
        return commonService.dayData().toString();
    }



    @RequestMapping("/A1")
    public String A1() {
        String result = "A1 OK please wait a moment";
        log.info(result);
        A1.init();
        return result;
    }

    @RequestMapping("/A2")
    public String A2() {
        String result = "A2 OK please wait a moment";
        log.info(result);
        A2.init();
        return result;
    }

    @RequestMapping("/A3")
    public String A3() {
        String result = "A3 OK please wait a moment";
        log.info(result);
        A3.init();
        return result;
    }

    @RequestMapping("/A4")
    public String A4() {
        String result = "A4 OK please wait a moment";
        log.info(result);
        A4.init();
        return result;
    }

    @RequestMapping("/A5")
    public String A5() {
        String result = "A5 OK please wait a moment";
        log.info(result);
        A5.init();
        return result;
    }

    @RequestMapping("/A17")
    public String A17() {
        String result = "A17 OK please wait a moment";
        log.info(result);
        A17.init();
        return result;
    }

    @RequestMapping("/V17")
    public String V17() {
        String result = "V17 OK please wait a moment";
        log.info(result);
        V17.init();
        return result;
    }


    @RequestMapping("/a-daily-limit-1")
    public String aDailyLimit1() {
        String result = "a-daily-limit-1 OK please wait a moment";
        log.info(result);
        aDailyLimit1Service.init();
        return result;
    }

    @RequestMapping("/a-daily-limit-2")
    public String aDailyLimit2() {
        String result = "a-daily-limit-2 OK please wait a moment";
        log.info(result);
        aDailyLimit2Service.init();
        return result;
    }

    @RequestMapping("/a-daily-limit-3")
    public String aDailyLimit3() {
        String result = "a-daily-limit-3 OK please wait a moment";
        log.info(result);
        aDailyLimit3Service.init();
        return result;
    }

    @RequestMapping("/lp")
    public String Lp() {
        String result = "LP OK please wait a moment";
        log.info(result);
        lp.init();
        return result;
    }



    @RequestMapping("/All")
    public String All() {
        String result = "All OK please wait a moment";
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        String today = dtf.format(LocalDate.now());
        Integer todayDataCount = gpMapper.getTodayDataCount(today);
        if (todayDataCount < 100) {
            return "today no data";
        }
        //A1.init();
        //A2.init();
        //A3.init();
        //A4.init();
        //A5.init();
        //A17.init();
        //V17.init();
        lp.init();
        aDailyLimit1Service.init();
        //aDailyLimit2Service.init();
        //aDailyLimit3Service.init();
        riseProportionService.todayRiseProportionSum();
        log.info(result);
        return result;
    }


}
